package com.yatong.controller;

import com.github.pagehelper.PageInfo;
import com.yatong.commons.util.PageData;
import com.yatong.entity.SysDept;
import com.yatong.service.SysDeptService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 部门表(SysDept)表控制层
 *
 * @author makejava
 * @since 2018-11-01 16:23:30
 */
@Controller
@RequestMapping("sysDept")
public class SysDeptController {
    /**
     * 服务对象
     */
    @Resource
    private SysDeptService sysDeptService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public SysDept selectOne(Integer id) {
        return this.sysDeptService.queryById(id);
    }

    /**
     * 访问部门首页
     * @param model
     * @return
     */
    @RequestMapping("/")
    public String sysDept_index(Model model){
        return "system/sysDept/sysDept_list";
    }

    /**
     * 通过查询条件查询多条数据
     *
     * @param sysDept
     * @return
     */
    @RequestMapping("/queryAll")
    @ResponseBody
    public Object queryAll(SysDept sysDept,@RequestParam Map<String, String> params){

        List<SysDept> sysDepts = this.sysDeptService.queryAll(sysDept);
//        PageInfo<SysDept> page = new PageInfo<SysDept>(sysDepts);
        return sysDepts;
    }

}